<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="sf" uri="http://www.springframework.org/tags/form"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>齐重后台管理系统</title>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/resources/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" charset="utf-8"
	src="<%=request.getContextPath()%>/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8"
	src="<%=request.getContextPath()%>/ueditor/ueditor.all.js"></script>
<LINK rel=stylesheet
	href="<%=request.getContextPath()%>/resources/css/admin/delCon.css">
<link rel=stylesheet type=text/css
	href="<%=request.getContextPath()%>/resources/css/backstage/back-nav.css">
<script type=text/javascript
	src="<%=request.getContextPath()%>/resources/js/backstage/back-nav.js"></script>
<link rel=stylesheet type=text/css
	href="<%=request.getContextPath()%>/resources/css/backstage/main.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/resources/css/admin/main.css"/>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/dwr/engine.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/dwr/interface/dwrService.js"></script>
<script type="text/javascript">
	$(function() {
		$('.confirm').click(function() {
			var proName = $('#proName').val();
			var proTypeId = $("#proTypeId").val();
			var id = $("#picId").val();
			var proMessage = UE.getEditor('proMessage').getContent();
			var propar = UE.getEditor('propar').getContent();
			dwrService.updatePic(proTypeId, proName, proMessage, propar, id);
			UE.getEditor('proMessage').setDisabled('fullscreen');
			UE.getEditor('propar').setDisabled('fullscreen');
			$('#proName').attr('disabled', true);
			$('#proTypeId').attr('disabled', true);
		});
		$('.cancel').click(function() {
			UE.getEditor('proMessage').setEnabled();
			UE.getEditor('propar').setEnabled();
			$('#proName').attr('disabled', false);
			$('#proTypeId').attr('disabled', false);
			$('#proTypeId').attr('disabled', false);
		});
		$('.ok').click(
				function() {
					var path = $("#path").val();
					var proTypeId = $("#proTypeId").val();
					window.location.replace(path + '/admin/topic/showPic/'
							+ proTypeId+".do");
				});
		$("#checkbox").click(function() {
			var id = $(this).attr('idv');
			if ($(this).is(':checked')) {
				dwrService.updateIndexImg(id, 1);
			} else {
				dwrService.updateIndexImg(id, 0); 
			}
		});
	});
</script>
</head>
<body>
<jsp:include page="/jsp/admin/top.jsp"></jsp:include>
<div class="content-box">
<jsp:include page="/jsp/admin/nav.jsp"></jsp:include>
	<input type="hidden" value="${pic.id }" id="picId" />
	<input type="hidden" value="<%=request.getContextPath()%>" id="path" />
	<table id="ok_attach" style="border-collapse: collapse">
		<thead>
			<tr id="head" style="">
				<td width=150px;><span>产品缩略图</span></td>
				<td width=100px;><span>产品类型</span></td>
				<td width=100px;><span>产品名称</span></td>
				<td width=350px;><span>产品描述</span></td>
				<td width=350px;><span>产品参数</span></td>
			</tr>
		</thead>
		<tbody id="tbody">
			<sf:form method="post" modelAttribute="pic" id="addForm">
				<td><img
					src="<%=request.getContextPath()%>/resources/upload/thumbnail/${pic.newName}" />
					<div>
					<c:choose>
								<c:when test="${pic.isIndexPic==1}">
									推荐?<input type='checkbox' id='checkbox' idv='${pic.id }' checked="true">
								</c:when>
								<c:otherwise>
									推荐?<input type='checkbox' id='checkbox' idv='${pic.id }'>
								</c:otherwise>
							</c:choose>
						<div></td>
				<td><select class="proType" id="proTypeId"
					style="width: 100px; height: 30px; border-radius: 5px;; margin-bottom: 10px; font-size: 13px; outline: none;">
						<c:forEach items="${product }" var="p">
							<c:choose>
								<c:when test="${p.name==c.name }">
									<option selected="selected" value="${p.id }">${p.name }</option>
								</c:when>
								<c:otherwise>
									<option value="${p.id }">${p.name }</option>
								</c:otherwise>
							</c:choose>
						</c:forEach>
				</select></td>
				<td><textarea class='proNameText' id="proName">${pic.attName }
				</textarea></td>
				<td><sf:textarea id="proMessage" path="picMessage"
						style="width:350px; height:200px;" /> <script
						type="text/javascript">
							var ue = UE.getEditor('proMessage', {
								toolbars : [ [ 'fullscreen', 'undo', 'redo',
										'bold', 'fontsize', 'justifyleft',
										'justifyright', 'justifycenter',
										'justifyjustify', 'forecolor' ] ],
								autoHeightEnabled : false,
								autoFloatEnabled : true
							});
						</script></td>
				<td><sf:textarea id="propar" path="proPar"
						style="width:350px; height:200px;" /> <script
						type="text/javascript">
							var ue = UE.getEditor('propar', {
								toolbars : [ [ 'fullscreen', 'undo', 'redo',
										'bold', 'fontsize', 'justifyleft',
										'justifyright', 'justifycenter',
										'justifyjustify', 'forecolor' ] ],
								autoHeightEnabled : false,
								autoFloatEnabled : true
							});
						</script></td>
			</sf:form>
		</tbody>
	</table>
	<div class="b-box">
		<div class="bfont confirm">确定</div>
		<div class="bfont cancel">修改</div>
		<div class="bfont ok">完成</div>
	</div>
	</center>
</div>
</body>
</html>